package com.link.wseller.mapper;

import com.link.wseller.domain.ProductCategory;
import org.apache.ibatis.jdbc.SQL;

public class ProductCategorySqlProvider {

    public String insertSelective(ProductCategory record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("product_category");
        
        if (record.getCategoryId() != null) {
            sql.VALUES("category_id", "#{categoryId,jdbcType=INTEGER}");
        }
        
        if (record.getCategoryName() != null) {
            sql.VALUES("category_name", "#{categoryName,jdbcType=VARCHAR}");
        }
        
        if (record.getCategoryType() != null) {
            sql.VALUES("category_type", "#{categoryType,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            sql.VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.VALUES("update_time", "#{updateTime,jdbcType=TIMESTAMP}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(ProductCategory record) {
        SQL sql = new SQL();
        sql.UPDATE("product_category");
        
        if (record.getCategoryName() != null) {
            sql.SET("category_name = #{categoryName,jdbcType=VARCHAR}");
        }
        
        if (record.getCategoryType() != null) {
            sql.SET("category_type = #{categoryType,jdbcType=INTEGER}");
        }
        
        if (record.getCreateTime() != null) {
            sql.SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdateTime() != null) {
            sql.SET("update_time = #{updateTime,jdbcType=TIMESTAMP}");
        }
        
        sql.WHERE("category_id = #{categoryId,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}